package org.ls.petclinic.dao.impl;

import org.ls.petclinic.dao.VisitsDao;
import org.ls.petclinic.pojo.Visits;

import java.util.List;

/**
 * @author 浪矢先生
 * @description
 * @create 2022-12-06 14:41
 */
public class VisitsDaoImpl extends BaseDao implements VisitsDao {
    @Override
    public int add(Visits visits) {
        return update("insert into visits(petId,visitDate,description) values(?,?,?)",visits.getPetId(),visits.getVisitDate(),visits.getDescription());
    }

    @Override
    public List<Visits> getByPetId(long l) {

        return queryForList(Visits.class,"select * from visits where petId=?",l);
    }

    @Override
    public List<Visits> all() {

        return queryForList(Visits.class,"select * from visits order by visitDate desc");
    }
}
